package com.coc.web;

import com.sun.org.glassfish.gmbal.ParameterNames;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jboss.logging.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.lang.annotation.Target;

@Controller
@RequestMapping("/aop")
@ResponseBody
@Api(tags = "AOP测试接口")
public class AopTestController {

    private static final Logger logger = LoggerFactory.getLogger(AopTestController.class);

    @RequestMapping(value = "/test1",method = RequestMethod.POST)
//    @PostMapping("/aop/test1")
    @ApiOperation(value = "AOP 测试接口 1",  notes = "演示AOP是否成功", tags = "1.0.0", httpMethod = "POST")
    public Object test1(){
        logger.info("/aop/test1");
        if (1==1) {
//            int a = 1/0;
            throw new RuntimeException("sb");
        }
        logger.info("ok!!!!");
        return "ok";
    }

    @RequestMapping(value = "", method = RequestMethod.GET)
    @ApiOperation(value = "AOP 测试接口 2",  notes = "演示AOP 2是否成功", tags = "1.0.0", nickname = "周某")
    public Object sayHello ( @ApiParam(name = "name", value = "姓名", required = true) @RequestParam("name") String name) {
        return "hello " + name ;
    }



}
